package com.wzq.animal.common.exception;

public class GlobalException extends RuntimeException {
    //此处异常类得名字建议用项目名加上Exception，整个项目的通用异常
    private StatusCode statusCode;
    private Object obj;

    public GlobalException(StatusCode statusCode) {
        this.statusCode = statusCode;
    }

    public GlobalException(StatusCode statusCode, Object obj) {
        this.statusCode = statusCode;
        this.obj = obj;
    }

    public StatusCode getStatusCode() {
        return statusCode;
    }

    public Object getObj() {
        return obj;
    }

    //用来输出异常信息和状态码
    public void printException(GlobalException e) {
        StatusCode statusCode = e.getStatusCode();
        System.out.println("异常代码：" + statusCode.getCode() + ",异常信息：" + statusCode.getMsg());
    }

}
